package com.itheima.zuoye2.zy3;

import java.util.Comparator;
import java.util.Map;
import java.util.TreeMap;

public class Test {
    public static void main(String[] args) {
        TreeMap<ModelWorker,String > map = new TreeMap<>(Comparator.comparingInt(ModelWorker::getAge));
        map.put(new ModelWorker("张三",18),"北京");
        map.put(new ModelWorker("李四",19),"上海");
        map.put(new ModelWorker("王五",20),"广州");
        map.put(new ModelWorker("赵六",21),"深圳");
        map.put(new ModelWorker("田七",22),"杭州");
        map.remove(new ModelWorker("张三",18));
        map.put(new ModelWorker("李四",19),"郑州");
        map.forEach((k,v)->
                System.out.println(k.getAge()+"岁的"+k.getName()+"---"+v));
        System.out.println("-------------------------");
      for (Map.Entry<ModelWorker, String> entry:map.entrySet()){
          System.out.println(entry.getKey().getAge()+"岁的"+entry.getKey().getName()+"---"+entry.getValue());
      }


    }
}
